Skip to content

Add Wait command and delayed screenshot handling; sanitize screen-element history to limit verbosity#99

Closed
Android-PowerUser wants to merge 2 commits into
test-termux-command-function-in-screen-operatorfrom
limit-screen-elements-to-3-most-recent
Closed

Add Wait command and delayed screenshot handling; sanitize screen-element history to limit verbosity#99
Android-PowerUser wants to merge 2 commits into
test-termux-command-function-in-screen-operatorfrom
limit-screen-elements-to-3-most-recent

Conversation

@Android-PowerUser
Copy link
Copy Markdown
Owner

Motivation

  • Allow the AI to schedule delayed screenshots and avoid triggering multiple immediate screenshot requests by introducing a Wait command and delaying screenshot execution.
  • Prevent chat history bloat and leaking outdated UI details by sanitizing repeated "Screen elements:" sections and keeping only the most recent relevant ones.
  • Make unit tests more stable by enabling default return values for unit tests in the Gradle config.

Description

  • Add a new Command.Wait(seconds: Long) type and parsing support in CommandParser with a regex and logging, and display the wait command in the UI (PhotoReasoningScreen).
  • Implement delayed screenshot behavior in ScreenOperatorAccessibilityService via a pendingScreenshotDelayMillis field and a new executeTakeScreenshotCommand() function that either executes immediately or posts a delayed capture using handler.postDelayed, preserving previous screenshot broadcast behavior.
  • Introduce PhotoReasoningScreenElementHistoryPolicy to sanitize message lists by marking older "Screen elements:" sections as "no longer relevant" and keep at most three recent relevant sections, and integrate this sanitizer across history builders, mutations, view model API payload construction, saving/loading of chat history, and other relevant places (PhotoReasoningHistoryBuilder, PhotoReasoningMessageMutations, PhotoReasoningViewModel, etc.).
  • Add unit test support: enable testOptions.unitTests.isReturnDefaultValues = true in app/build.gradle.kts.
  • Add tests: PhotoReasoningScreenElementHistoryPolicyTest to verify sanitization behavior and extend CommandParserTest to assert Wait parsing.

Testing

  • Ran unit tests with ./gradlew :app:testDebugUnitTest, and all unit tests including PhotoReasoningScreenElementHistoryPolicyTest and the extended CommandParserTest passed.
  • No instrumentation or UI tests were run as part of this change.

Codex Task

Copy link
Copy Markdown
Contributor

@amazon-q-developer amazon-q-developer Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Wait command feature implementation looks good overall. The changes are well-coordinated across all the necessary files:

  • ✅ Command definition added correctly
  • ✅ Parser patterns updated with proper regex
  • ✅ Execution logic properly handles delays before screenshot
  • ✅ UI displays Wait commands correctly
  • ✅ Unit test coverage added

The implementation correctly allows delaying screenshot capture, which addresses the stated requirement. No blocking issues found.


You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.

@Android-PowerUser Android-PowerUser deleted the branch test-termux-command-function-in-screen-operator May 11, 2026 18:20
@Android-PowerUser Android-PowerUser deleted the limit-screen-elements-to-3-most-recent branch May 11, 2026 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant